﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RiderShop.Mobile.Common.Component;
using System.Web.Mvc;
using Kevin.Comm.Utility.Crypto;
using RiderShop.Mobile.Modle.MyAccount;
using Kevin.Shop.Business.Service.Entity.Helper;
using Kevin.Shop.Business.Core.Components.Responser;
using Kevin.Shop.Business.Service.Entity.Core.Member;
using Kevin.Shop.Business.Service.Entity.SalesManagement.GiftCard;
using Kevin.Shop.Business.Core.Components;
using RiderShop.Mobile.ServiceEntity.Store;
using System.IO;
using System.Net;

namespace RiderShop.Mobile.Controllers.MyAccount
{
    public partial class MyAccountController : ThemeController
    {
        #region Get User GiftCard
        /// <summary>
        /// 得到用户的优惠券列表
        /// </summary>
        /// <param name="status">status=0未使用|status=2已使用|status=4已过期</param>
        /// <param name="pageIndex">当前页的索引</param>
        /// <returns>优惠券列表</returns>
        [HttpGet]
        [Authorize]
        public ActionResult MyGiftCard(int status = 0, int pageIndex = 0)
        {
            MyGiftCardModel myGiftCardModel = new MyGiftCardModel();
            DbQueryResult<List<GiftCardInfoExtend>> result = myGiftCardModel.GetUserGiftCards(status, pageIndex, 1);
            if (result != null && result.Data.Count > 0)
            {
                myGiftCardModel.GiftCardList = result.Data;

                return View(WebClientContext.Current.SiteTheme, "MyAccount", "MyGiftCard", "_MobileLayout", myGiftCardModel);
            }
            return View(WebClientContext.Current.SiteTheme, "MyAccount", "MyGiftCard", "_MobileLayout", myGiftCardModel);
        }

        /// <summary>
        /// 得到用户的优惠券列表
        /// </summary>
        /// <param name="status">status=0未使用|status=2已使用|status=4已过期</param>
        /// <param name="pageIndex">当前页的索引</param>
        /// <returns>优惠券列表</returns>
        //[HttpGet]
        public ActionResult MyGiftCardByAjaxRequest(int status, int pageIndex)
        {
            MyGiftCardModel myGiftCardModel = new MyGiftCardModel();
            DbQueryResult<List<GiftCardInfoExtend>> result = myGiftCardModel.GetUserGiftCards(status, pageIndex, 1);
            if (result != null && result.Data.Count > 0)
            {
                myGiftCardModel.GiftCardList = result.Data;
            }
            return PartialView("MyGiftCardPartial", myGiftCardModel);
        }
        #endregion
    }
}
